package com.lenovo.uitest.power;

import java.io.IOException;

import android.hardware.Camera.ShutterCallback;
import android.media.UnsupportedSchemeException;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
import android.view.KeyEvent;

import com.android.uiautomator.core.Configurator;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.lenovo.uitest.base.CMP;
import com.lenovo.uitest.base.QUICKSET;
import com.lenovo.uitest.base.CTRL;

public class PowerCase extends PowerBase implements PowerInterface,GeneralInterface{

	@Override
	public void testShutDown(){
    shutDownForTming();
	}

	@Override
	public void testOnAirMode() {
		setAirplaneForSeting(CTRL.ON);				
	}

	@Override
	public void testOffAirMode() {
		setAirplaneForSeting(CTRL.OFF);			
	}

	@Override
	public void testHightLightLcd() {
		//setLCDBrightnessUp(10);
		setLCDLight(CTRL.HIGHT);
	}

	@Override
	public void testLowLightLcd() {
		//setLCDBrightnessUp(10);	
		setLCDLight(CTRL.LOW);
	}

	@Override
	public void testLaunchCamera() {
		LaunchApp(CMP.CAMERA_PACKAGENAME_SUPER, CMP.CAMERA_ACTIVITY_SUPER);	
		LaunchApp(CMP.CAMERA_PACKAGENAME_LITE, CMP.CAMERA_ACTIVITY_LITE);
        	
	}

	@Override
	public void testFocuCamera() {
		// 设置连续对焦
		//camaraSettingAFC();
		setQuickSetting(QUICKSET.BRIGHTNESS, CTRL.ON);
		
	}

	@Override
	public void testCloseCamera() {
		pressBack(3);		
	}

	@Override
	public void testPlayVideo() {
		playVideo();		
	}

	@Override
	public void testPlayVideoFullScreen() {
	setVideoFullScreen();
			
	}

	@Override
	public void testVOLHigh() {
		setVolControl(CTRL.HIGHT);		
	}

	@Override
	public void testVOLLow() {
		setVolControl(CTRL.LOW);		
	}

	@Override
	public void testPlayMp3() {
		playMp3();		
	}

	@Override
	public void testRunNeocore() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void testOpenSinaFor2G() {
		setAirplaneForSeting(CTRL.OFF);	
		setWlanCTRL(CTRL.OFF);
		setNetData(CTRL.GRRS);
		pressBack(5);
		closeAllApp();
	    String sinaSite="http://3g.sina.com.cn";
		launchBrowserAndToSite(sinaSite);
		
	}

	@Override
	public void testOpenSinaFor3G() {
		setAirplaneForSeting(CTRL.OFF);
		setWlanCTRL(CTRL.OFF);
		setNetData(CTRL.TDWCDMA);
		pressBack(5);
		closeAllApp();
	    String sinaSite="http://3g.sina.com.cn";
		launchBrowserAndToSite(sinaSite);
	}

	@Override
	public void testOpenSinaForWifi() {
		setAirplaneForSeting(CTRL.OFF);	
		setWlanCTRL(CTRL.ON);
		//setNetData(CTRL.TDWCDMA);
		pressBack(5);
		closeAllApp();
	    String sinaSite="http://3g.sina.com.cn";
		launchBrowserAndToSite(sinaSite);
		
	}
	@Override
	public void testVoiceCallHost() {
		String phone="10086";
		Bundle bundle=getParams();
		if (bundle.getString("phone")!=null) {
			phone=bundle.getString("phone");
		}	
		callVoicePhone(phone);		
	}

	@Override
	public void testVoiceCallClient() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void testVideoCallHost() {
		String phone="10086";
		Bundle bundle=getParams();
		if (bundle.getString("phone")!=null) {
			phone=bundle.getString("phone");
		}
		callVideoPhone(phone);		
	}

	@Override
	public void testVideoCallClient() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void testEndCall() {
		device().pressKeyCode(KeyEvent.KEYCODE_ENDCALL);
		
	}

	@Override
	public void testUnlock() {
		Unlock();		
	}

	@Override
	public void testClearBG() {
		closeAllApp();
	}

	@Override
	public void testSleep() {
	 try {
		device().sleep();
	} catch (RemoteException e) {
		e.printStackTrace();
	}
		
	}

	@Override
	public void testPressBack() {
		pressBack(5);		
	}

	@Override
	public void testPressHome() {
      device().pressHome();
      device().pressHome();
      device().pressHome();
		
	}

	@Override
	public void testDevelper() {
		//打开开发人员选项，设置不锁定屏幕
		OpenDevlepNOlockScreen();
	}

	@Override
	public void testStartVideo() {
		// 开始录像
		startVideo();
		
	}

	@Override
	public void testCloseVideo() {
		// 结束录像
		closVideo();
		
	}

	@Override
	public void testStartphotograph() {
		// 拍一张照片
		//device().pressKeyCode(KeyEvent.KEYCODE_VOLUME_UP);
		Startphotograph();
	}

	@Override
	public void testfreezeRotation() {
		// 关闭自动旋转
		try {
			device().setOrientationNatural();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void testUnfreezeRotation() {
		// 打开自动旋转
		try {
			device().unfreezeRotation();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		
	}

	@Override
	public void testDelay() {
	
		setDelayed(CTRL.SECOND_15);
		
	}
  
}
